package com.digital.herbarium.Controller;

import com.digital.herbarium.annotation.CheckToken;
import com.digital.herbarium.Entity.Comment;
import com.digital.herbarium.Entity.ResponseResult;
import com.digital.herbarium.annotation.Log;
import com.digital.herbarium.service.CommentService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/comment")
public class CommentController {

    @Autowired
    CommentService commentService;


    @GetMapping("getCommentInfo")
    @Log("comment")
    public ResponseResult getCommentInfo(Comment comment){
        return ResponseResult.SUCCESS().setData( commentService.getCommentInfo(comment));
    }


    @GetMapping("getManagerCommentInfo")
    @CheckToken()
    @Log("comment")
    public ResponseResult getManagerCommentInfo(Comment comment){
        return ResponseResult.SUCCESS().setData( commentService.getCommentInfo(comment));
    }


    @PostMapping("addCommentInfo")
    // @CheckToken()
    public  ResponseResult addCommentInfo(Comment  comment){
        commentService.addCommentInfo(comment);
        return ResponseResult.SUCCESS().setData("添加成功");
    }

    @PostMapping("editCommentInfo")
    // @CheckToken()
    public  ResponseResult editCommentInfo(Comment comment){
        commentService.editCommentInfo(comment);
        return ResponseResult.SUCCESS().setData("更新成功");
    }

    @GetMapping("delCommentInfo")
    // @CheckToken()
    public ResponseResult delCommentInfo(String id){
        commentService.delCommentInfo(id);
        return  ResponseResult.SUCCESS().setData("删除成功");
    }

    @PostMapping("to_top")
    // @CheckToken()
    public  ResponseResult to_top(Comment comment){
        commentService.to_top(comment);
        return ResponseResult.SUCCESS().setData("更新成功");
    }

}
